APPENDIX A : Diamond Components |
The IST Diamonds are a collection of useful components and layout classes that have been designed with the needs of the developer in mind. Each class has been made as lightweight as possible, while still delivering maximum functionality. They have been constructed to make them easy to re-use with considerable thought given to the methods provided to allow the developer to control the class. All classes adhere to the JavaBeans conventions. All classes are documented to give javadoc documentation.
IST's Diamonds components are:
See the Buttons section on page 192. |
See the FramedPanel section on page 194. |
See the Separator section on page 194. |
See the Controllers: Knobs and Meters, Sliders, and Progress Bar section on page 194. |
See the Splitter section on page 195. |
See the StatusBar section on page 195. |
See the SuperGrid Layout section on page 195. |
See the DlogTemplateLayout section on page 195. |
See the Book (TabbedPanel) section on page 196. |
See the ToolBar section on page 197. |
See the Bezel Panel section on page 197. |
Diamonds provide the following buttons:
All buttons provide label, button, toggle or multi-state behaviour, and use the JDK 1.1 event model to fire action events when the button state changes. The events can be fired when the button is pressed or released. The buttons also support tips.
The simplest button in the Diamonds set is the arrow button which just draws a triangle, representing an arrow. This can be set to point in one of eight different directions:
1. | NORTH |
2. | SOUTH |
3. | EAST |
4. | WEST |
5. | NORTHEAST |
6. | NORTHWEST |
7. | SOUTHEAST |
8. | SOUTHWEST |
The DrawnButton is a button whose paint method can be overridden to put an image on the button. We provide some subclasses that have already done this. It can have shadows on any or all of its sides, and these can be round or square.
Note - With the Diamonds, a label can be created by setting the behaviour of a DrawnButton to LABEL.
The Polygon Button, as the name suggests, allows the developer to produce a button in any polygon shape. It is a DrawnButton subclass, shaped as an arbitrary polygon. The Diamonds code works out all the appropriate shading to give the natural 3D appearance.
RoundButton is similar to a PolygonButton, but has code to use an Oval as its polygon.
The FlexiButton class can display images, text, or both together. It also supports separate appearances for the pressed, released, disabled and enabled states. This is the button to use for tabs in a Book component, as detailed in the Book (TabbedPanel) section on page 196.
The FramedPanel can be used to draw a frame around groups of related components, with an optional title. A variety of layouts and appearances are provided.
A simple but useful class, this lets you add separators to your visual layout. Full customization of the separator is supported.
Controllers are UI elements which allow the developer to display numerical values in a graphical manner, and can allow the user to input data using the mouse. There are two types; sliders and AngleControllers.
Sliders display the information as a thumb, which is placed somewhere along a track; the position of the thumb represents the value. There are two types of slider; the lightweight version, which is provided as a diamond, and the somewhat more complex MWT version, which mimics the Motif Scale widget in appearance.
The ProgressBar is a subclass of Slider and is designed to show how far through a particular process a program might be; for example, a web browser might use it to show how far it has progressed with a download. The ProgressBar can also take input; its only true difference is in its appearance, which has been optimized for output.
AngleControllers show a value in terms of an angle; a Knob shows it in the form of a control which can be `turned' by the mouse, much like the volume control on many music systems. A Meter is designed more for output (although it can also be used for input); it takes the form of a needle which points to a value on a semicircular scale (rather like, say, the dial on an analogue ammeter).
A splitter is a panel which lays out its children in a grid. Between the children are `sashes', which can be dragged around. Dragging them allows the user to determine how much space is given over to each child. The cursor changes when over a sash to hint to the user that this can be done.
Maximum and minimum sizes can be set for the height of each row and for the width of each column. Splitters can be nested inside other splitters to allow quite complex user-resizeable layouts.
The StatusBar is simply a Panel which draws a shadow around itself and around each of its children. The example below uses it in conjunction with a SuperGrid to provide a simple status bar.
The SuperGrid class provides the ideal layout control for most dialogs. What most developers need is a cross between the AWT Grid and the AWT GridBag layout manager. The SuperGrid provides the ability to layout simple tabular arrangement of components. Individual columns expand so that they are the width of the widest component in the column and individual rows expand so that they are the height of the tallest component in the row. SuperGrid provides fill and alignment properties so that simple dialogs containing, for example, labelled textfields can be laid out so that the labels are right aligned against the textfields and the textfields expand to fill unfilled areas.
The DlogTemplateLayout gives you a default layout suitable for simple dialogs such as those used for displaying messages or errors. Any buttons added to a container with this type of layout are added in a horizontal line at the bottom of the container. If you add another container, such as a Panel, it is put at the top. A separator is provided "free" and placed above the line of buttons. Figure 13-5 shows an example hierarchy using DlogTemplateLayout along with the associated dynamic display.
Note - If you use the DlogTemplateLayout in your application, you will need to add the mwt.jar file to your CLASSPATH. This jar file is found in the Visaj install directory.
The TabbedPanel class provides an easy-to-use tab control component for Java. It allows you to dynamically add and remove tabs, position them along the top, sides or bottom, place images, text, or combined images and text on the tabs. The TabbedPanel treats FlexiButtons as tabs and anything else as pages. These can be added in any order - the nth tab will match the nth page. If there are more tabs than pages, all extra tabs will show the last page.
Note - The Book component expects to have FlexiButtons as tabs. If these are not used, the Book cannot function as described above. See the Buttons section on page 193 for more details on that component.
Possible uses:
The ToolBar is a panel which draws a border around itself. Future releases will have docking and drag-and-drop support.
BezelPanel is a container with a bezelled frame. The shadow thickness and insets can be adjusted via the Property Sheet. You may also provide a pixmap image to use for the frame edging itself.
When you use the Diamond components in your application, make sure that the library or directory containing the Diamond class files is in your CLASSPATH. The Diamond class files are in the diamonds.jar file, which is found in the Visaj install directory. This jar file must be in your CLASSPATH.
For DlogTemplateLayout you will need the mwt.jar file, which is also found in the Visaj install directory.